package com.umeng.soexample;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * @author wupuquan
 * @version 1.0
 * @since 2018/3/22 14:09
 */
public class ShareAdapter extends BaseAdapter{

    private Context mContext;
    private List<String> mList;

    public ShareAdapter(Context context, List<String> list) {
        this.mContext = context;
        this.mList = list;
    }

    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (view == null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.list_item_share, null);
            viewHolder = new ViewHolder();
            viewHolder.textView = view.findViewById(R.id.btn_item);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.textView.setText(mList.get(i));

        return view;
    }

    static class ViewHolder {
        TextView textView;
    }
}
